<?php

class Response
{
    /**
     * 成功返回
     * @param $result
     * @param $code
     * @param string $message
     * @return array
     */
    public static function Success($result, $message = "", $code = 200)
    {
        header('Content-type: application/json');
        $data = array(
            'result' => $result,
            'code' => $code,
            'message' => $message
        );
        echo json_encode($data);
        exit();
    }

    /**
     * 失败返回
     * @param $code
     * @param $message
     * @return array
     */
    public static function Error($code, $message)
    {
        header('Content-type: application/json');
        $data = array(
            'result' => '',
            'code' => $code,
            'message' => $message
        );
        echo json_encode($data);
        exit();
    }
}